package com.service;


import com.mapper.userMapper;
import com.pojo.user;
import com.util.factory;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class userService {
    SqlSessionFactory sqlSessionFactory = factory.getSqlSessionFactory();

    public List<user> userselectAll()
    {
        SqlSession sqlSession = sqlSessionFactory.openSession();
//        获取brandmapper
        userMapper mapper = sqlSession.getMapper(userMapper.class);
//          调用查询的方法
        List<user> users = mapper.user_selectAll();
        return users;
    }

    public user userlogin(String userAccount,String userPassword)
    {
        SqlSession sqlSession = sqlSessionFactory.openSession();
//        获取brandmapper
        userMapper mapper = sqlSession.getMapper(userMapper.class);

        user user = mapper.user_login(userAccount,userPassword);
        return user;
    }

    //根据id查询String
    public String  user_selectName(int id)
    {
        SqlSession sqlSession = sqlSessionFactory.openSession();
//        获取brandmapper
        userMapper mapper = sqlSession.getMapper(userMapper.class);

        String s = mapper.user_selectName(id);
        return s;
    }


}
